<template>
  <div class="echarts">
    <div
      :style="{ width: chartWidth, height: chartHeight }"
      class="no-data"
      v-if="this.chartData.rows && this.chartData.rows.length == 0"
    >
      <span>画图展无数据</span>
    </div>
    <div
      ref="bar"
      :style="{ width: chartWidth, height: chartHeight }"
    ></div>
  </div>
</template>

<script>
import OptionBar from './../echarts-js/echarts-bar'
import echartsMixin from './../echarts-js/echarts-mixin'
export default {
  mixins: [echartsMixin],
  mounted() {
    //调用初始化画图函数
    this.initChart()
  },
  methods: {
    //初始化画图
    initChart() {
      let theme = ''
      if (this.settings.theme) {
        theme = this.settings.theme
      }
      //设置画图对象
      this.myChart = this.$echarts.init(this.$refs.bar, theme)
      //设置OptionBar对象
      const bar = new OptionBar(this.chartData, this.settings, this.extend)
      //开始画图
      this.myChart.setOption(bar.option)
    },
  }
}
</script>

<style scoped>
.no-data {
  position: absolute;
  background-color: #fff;
  z-index: 999;
  display: flex;
  justify-content: center;
  align-items: center;
}
</style>